#include "SphereParser.h"


SphereParser::SphereParser(void)
{
}


SphereParser::~SphereParser(void)
{
}

SphereParser::SphereParser(float radius, int slices, int stacks, string tx_id, string mat_id): PrimitiveParser(tx_id, mat_id)
{
	this->radius = radius;
	this->slices = slices;
	this->stacks = stacks;

	sph_glQ = gluNewQuadric();
	gluQuadricOrientation(sph_glQ, GLU_OUTSIDE);
	gluQuadricDrawStyle(sph_glQ, GLU_FILL);
	gluQuadricTexture(sph_glQ, GL_TRUE);
	gluQuadricNormals(sph_glQ,GLU_SMOOTH);
}

void SphereParser::render(){
	if(texture_id != "none" && texture_id != "inherit")
		render(texture);
	else{
		//gluQuadricOrientation(sph_glQ, GLU_OUTSIDE);
		gluSphere(sph_glQ,radius,slices,stacks);
	}
}

void SphereParser::render(TextureParser* tx){
	glEnable(GL_TEXTURE_2D);
	//gluQuadricTexture(sph_glQ, true);
	glBindTexture(GL_TEXTURE_2D, tx->tx_id);

	//gluQuadricOrientation(sph_glQ, GLU_OUTSIDE);
	gluSphere(sph_glQ,radius,slices,stacks);
	
	glDisable(GL_TEXTURE_2D);
}